home *** CD-ROM | disk | FTP | other *** search
- /* FindReq.xdme © 1992 Fergus Duniho */
- /* Requester for Find, Find & Replace, Set Find and Replace Strings */
-
- if ~show("L","rexxarplib.library") then
- if ~addlib("rexxarplib.library",0,-30,0) then exit
-
- F = GetEnv('F')
- R = GetEnv('R')
- options results
- address 'XDME.1'
- 'rxresult $igncase'
- igncase = result
- N = -1
- 'blocktype character'
-
- Address AREXX '"Call CreateHost CPORT, NOTPORT"'
- Do Until ShowList(P,CPORT)
- Call Delay(10)
- End
-
- IDCMP = 'GADGETUP+CLOSEWINDOW'
- FLAGS = 'ACTIVATE+BACKFILL+WINDOWDRAG+WINDOWCLOSE+WINDOWDEPTH'
- TTEXT = 'XDMD Find & Replace Requester © 1993 Fergus Duniho'
-
- Call OpenWindow CPORT, 50, 25, 500, 90, IDCMP, FLAGS, TTEXT
-
- Call SetDrMd CPORT, COMPLEMENT
- Call Move CPORT, 20, 22
- Call Text CPORT, 'Find String : '
- Call AddGadget CPORT, 155, 14, 'F', F, 'F = "(" || strip("%g") || ")"; Call ActivateGadget CPORT, "R"', 300
-
- Call Move CPORT, 20, 42
- Call Text CPORT, 'Replace String : '
- Call AddGadget CPORT, 155, 34, 'R', R, 'R = "(" || strip("%g") || ")"; Call ActivateGadget CPORT, "N"', 300
-
- Call Move CPORT, 20, 62
- Call Text CPORT, 'Replacements : '
- Call AddGadget CPORT, 155, 54, 'N', N, 'N = "%g"', 50
-
- Call Move CPORT, 230, 62
- Call Text CPORT, 'Ignore Case : '
- Call AddGadget CPORT, 350, 54, 'ign', ' On ', 'igncase = 1; Call ICase'
- Call AddGadget CPORT, 400, 54, 'sen', ' Off ', 'igncase = 0; Call ICase'
- Call AddGadget CPORT, 15, 74, 'find', ' Find ', 'find F; Call Hlight'
- Call AddGadget CPORT, 80, 74, 'prev', ' Prev ', 'findstr F; prev; Call Hlight'
- Call AddGadget CPORT, 145, 74, 'repfind', ' Replace & Find ', 'Call Repfind'
- Call AddGadget CPORT, 290, 74, 'replace', ' Replace N Times ', 'Call ReplaceN'
- Call AddGadget CPORT, 440, 74, 'set', ' Set ', 'Call Set; Exit'
- Call ModifyHost CPORT, CLOSEWINDOW, 'Call Quit CPORT; Exit'
-
- Call ICase
- Call ActivateGadget CPORT, 'F'
-
- Call OpenPort MAINPORT
- Do Until ShowList(P, MAINPORT)
- Call Delay(10)
- End
-
- Call SetNotify(CPORT, GADGETUP, MAINPORT)
- Call SetNotify(CPORT, CLOSEWINDOW, MAINPORT)
-
- Do Forever
- Call WaitPkt(MAINPORT)
- PACKET = GetPkt(MAINPORT)
- If PACKET ~== Null() Then Interpret GetArg(packet, 0)
- End
- Exit
-
- ICase:
- if igncase = 1 then do
- Call SetGadget CPORT, 'ign', on
- Call SetGadget CPORT, 'sen', off
- ignorecase on
- end
- else do
- Call SetGadget CPORT, 'ign', off
- Call SetGadget CPORT, 'sen', on
- ignorecase off
- end
- 'set igncase' igncase
- Return
-
- Set:
- Call Quit CPORT
- CASE = Compress(CASE)
- ignorecase CASE
- if F = "()" | F = "" then do
- 'unsetenv F'
- end
- else do
- 'setenv F' F
- end
- if R = "()" | R = "" then do
- 'unsetenv R'
- end
- else do
- 'setenv R' R
- end
- 'set Case' CASE
- Return
-
- Hlight:
- L = length(F) - 3
- ping 9
- unblock
- block
- C = "col +" || L
- C
- block
- C = "col -" || L
- C
- Return
-
- Repfind:
- findstr F
- repstr R
- 'scanf %s'
- 'rxresult $scanf'
- Q = '(' || result || ')'
- if abbrev(Q, F) > 0 then do
- 'replace'
- end
- next
- Call Hlight
- Return
-
- ReplaceN:
- findstr F
- repstr R
- 'scanf %s'
- 'rxresult $scanf'
- Q = '(' || result || ')'
- if abbrev(Q, F) > 0 then do
- 'replace'
- end
- C = "repeat" N "nextr"
- C
- Return
-